package com.gong;

import org.apache.http.HttpHost;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Doc_Get {
        public static void main(String[] args) throws Exception {

            RestHighLevelClient esClient = new RestHighLevelClient(
                    RestClient.builder(new HttpHost("localhost", 9200, "http"))
            );

            // 查询数据
            GetRequest request = new GetRequest();
            request.index("user").id("1001");
            GetResponse response = esClient.get(request, RequestOptions.DEFAULT);

            System.out.println(response.getSourceAsString());

            esClient.close();
        }
    }

